package com.meilingcloud.biobank.domain.dto;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;

@Data
public class ContainerBatchDto implements Serializable {

    private static final long serialVersionUID = 1L;

    @JsonSerialize(using = ToStringSerializer.class)
    @NotNull(message = "父容器不能为空")
    private Long parentId;

    @NotNull(message = "冻存盒数量不能为空")
    @Min(value = 1, message = "冻存盒数量必须大于等于1")
    private Integer boxCount;

    @NotNull(message = "盒列数不能为空")
    @Min(value = 1, message = "盒列数必须大于等于1")
    private Integer boxColumn;

    @NotNull(message = "盒行数不能为空")
    @Min(value = 1, message = "盒行数必须大于等于1")
    @Max(value = 20, message = "盒行数必须小于等于20")
    private Integer boxRow;

    @NotBlank(message = "盒布局不能为空")
    private String boxLayout;

    @NotNull(message = "容器分区不能为空")
    private List<Subarea> subareas;

    @Data
    public static class Subarea implements Serializable {

        private static final long serialVersionUID = 1L;

        @JsonSerialize(using = ToStringSerializer.class)
        @NotNull(message = "容器类型不能为空")
        private Long containerTypeId;

        @NotNull(message = "容器分区数量不能为空")
        @Min(value = 1, message = "分区数量必须大于等于1")
        private Integer count;

        private Subarea child;
    }

}
